<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePatentApplyFilesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('patent_apply_files', function (Blueprint $table) {
            $table->id();
            $table->integer('patent_apply_id')->comment('申请关联ID');
            $table->string('name')->nullable()->comment('名称');
            $table->integer('user_id')->default(0)->comment('上传人ID');
            $table->string('path')->comment('路径');
            $table->string('mime', 100)->nullable()->comment('文件类型');
            $table->string('size', 20)->default(0)->comment('文件大小');
            $table->tinyInteger('is_preview')->default(0)->comment('是否可预览');

            $table->string('slug', 30)->nullable()->comment('标识');
            $table->tinyInteger('type')->default(0)->comment('文件类型值');
            $table->string('type_name', 30)->nullable()->comment('文件类型名');
            $table->string('user_name', 50)->nullable()->comment('上传人');

            $table->timestamps();

            $table->index('patent_apply_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('patent_apply_files');
    }
}
